﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeTop.hot100
{
    public class Solution137
    {
        public int SingleNumber(int[] nums)
        {
            int res = 0;

            for (int i = 0; i < 32; i++)
            {
                int total = 0;// 所以数的第i位加一起，一定是3的倍数
                for (int j = 0; j < nums.Length; j++)
                {

                    int curNum = nums[j];

                    //第i位是
                    total += (curNum >> i) & 1;//除以几次2，就是二进制的第i位到第0位的，与1求与


                }
                if (total % 3 != 0)
                {
                    //特殊数的第i位是1,
                    //1左移i位
                    res = res |(1<<i);


                }


            }
            return res;
        }
    }
}
